<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/list.css"/>
		<link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-table/1.17.1/bootstrap-table.min.css" rel="stylesheet">
		<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
			  integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" rel="stylesheet">
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
		<script crossorigin="anonymous"
				integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
				src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-table/1.17.1/bootstrap-table.min.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-table/1.17.1/locale/bootstrap-table-zh-CN.min.js"></script>
	</head>
	<body>
	<script>
		var form = layui.form
				, layer = layui.layer;
	</script>
	<table id="ed_list"></table>
	<script>
		$(function () {

			$("#ed_list").bootstrapTable({
				url: "/EDelivery/list.do", 	//请求地址
				striped: true,				//行显示间隔
				pageNumber: 1,				//初始化分页为1
				pagination: true,			//是否分页
				sidePagination: 'server',   //分页类型：服务器分页
				pageSize: 5,				//每页显示数
				pageList: [5, 10, 20],		//单元显示
				showRefresh: true,			//刷新按钮
				//发送请求数据
				queryParams: function (params) {
					var temp = {
						offset: params.offset,
						pageNumber: params.limit
					};
					return temp;
				},
				//关闭排序列按钮
				columns: [
					{
						title: "编号",
						field: "id",
						sortable: false
					},
					{
						title: "姓名",
						field: "name",
						sortable: false
					},
					{
						title: "手机号码",
						field: "phone",
						sortable: false
					},
					{
						title: "身份证",
						field: "idNumber",
						sortable: false
					},
					{
						title: "密码",
						field: "passWord",
						sortable: false
					},
					{
						title: "派件数",
						field: "deliveryNumber",
						sortable: false
					},
					{
						title: "注册时间",
						field: "registeredTime",
						sortable: false
					},
					{
						title: "上次登录时间",
						field: "lastTime",
						sortable: false
					},
					{
						field: 'operate',
						title: '操作',
						events: {
/*							'click #edit': function (e, value, row, index) {;
								editInfo(row.phone);
							},*/
							'click #delete': function (e, value, row, index) {
								deleteInfo(row.phone);
							}
						},
						formatter: function (value, row, index) {
							var result = "";
							// result += '<button id="edit" class="btn btn-info" data-toggle="modal" data-target="#editModal">编辑</button>';
							result += '<button id="delete" class="btn btn-danger" style="margin-left:10px;">删除</button>';
							return result;
						}
					}
				]
			})
/*
			// 修改信息
			function editInfo (phone) {
				location.href("update.html?phone="+phone)
			}
			*/

			// 删除信息
			function deleteInfo(phone) {
				$.ajax({
					type: 'post',
					url: '/EDelivery/delete.do',
					dataType: 'json',
					data: {
						phone: phone
					},
					success: function (data) {
						if (data.status === 0) {
							$('#ed_list').bootstrapTable('refresh');
						}
						else {
							alert('删除失败');
						}
					}
				})
			}
		});
	</script>
	</body>
</html>
